// Package sysin
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.11
package sysin

import (
	"context"
	"github.com/gogf/gf/v2/encoding/gjson"
	"hotgo/internal/library/hgorm/hook"
	"hotgo/internal/model/entity"
	"hotgo/internal/model/input/form"

	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/os/gtime"
)

// OrderVerifyLogUpdateFields 修改订单核销记录字段过滤
type OrderVerifyLogUpdateFields struct {
	OrderId   int64 `json:"orderId"   dc:"订单 id"`
	MemberId  int64 `json:"memberId"  dc:"核销用户 id"`
	ProductId int64 `json:"productId" dc:"核销产品"`
	StoreId   int64 `json:"storeId"   dc:"核销商家 id"`
	Count     int   `json:"count"     dc:"核销数量"`
}

// OrderVerifyLogInsertFields 新增订单核销记录字段过滤
type OrderVerifyLogInsertFields struct {
	OrderId    int64 `json:"orderId"   dc:"订单 id"`
	MemberId   int64 `json:"memberId"  dc:"核销用户 id"`
	ProductId  int64 `json:"productId" dc:"核销产品"`
	StoreId    int64 `json:"storeId"   dc:"核销商家 id"`
	BusinessId int64 `json:"businessId" dc:"核销商户 id"`
	Count      int   `json:"count"     dc:"核销数量"`
	CreatedBy  int64 `json:"createdBy" dc:"核销人"`
}

// OrderVerifyLogEditInp 修改/新增订单核销记录
type OrderVerifyLogEditInp struct {
	entity.OrderVerifyLog
}

func (in *OrderVerifyLogEditInp) Filter(ctx context.Context) (err error) {
	// 验证订单 id
	if err := g.Validator().Rules("required").Data(in.OrderId).Messages("订单 id不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证核销用户 id
	if err := g.Validator().Rules("required").Data(in.MemberId).Messages("核销用户 id不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证核销产品
	if err := g.Validator().Rules("required").Data(in.ProductId).Messages("核销产品不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	// 验证核销商家 id
	if err := g.Validator().Rules("required").Data(in.StoreId).Messages("核销商家 id不能为空").Run(ctx); err != nil {
		return err.Current()
	}

	return
}

type OrderVerifyLogEditModel struct{}

// OrderVerifyLogDeleteInp 删除订单核销记录
type OrderVerifyLogDeleteInp struct {
	Id interface{} `json:"id" v:"required#id不能为空" dc:"id"`
}

func (in *OrderVerifyLogDeleteInp) Filter(ctx context.Context) (err error) {
	return
}

type OrderVerifyLogDeleteModel struct{}

// OrderVerifyLogViewInp 获取指定订单核销记录信息
type OrderVerifyLogViewInp struct {
	Id int64 `json:"id" v:"required#id不能为空" dc:"id"`
}

func (in *OrderVerifyLogViewInp) Filter(ctx context.Context) (err error) {
	return
}

type OrderVerifyLogViewModel struct {
	entity.OrderVerifyLog
	CreatedBySumma *hook.MemberSumma `json:"createdBySumma" dc:"核销人摘要信息"`
}

// OrderVerifyLogListInp 获取订单核销记录列表
type OrderVerifyLogListInp struct {
	form.PageReq
	CreatedAt           []*gtime.Time `json:"createdAt"           dc:"核销时间"`
	OrderUid            string        `json:"orderUid"            dc:"订单UUID"`
	OrderTraceId        string        `json:"orderTraceId"        dc:"交易ID(流水号)"`
	OrderType           string        `json:"orderType"           dc:"订单类型(会员订单、团购订单、积分权益)"`
	StoreName           string        `json:"storeName"           dc:"门店名称"`
	StorePhone          string        `json:"storePhone"          dc:"门店电话"`
	ProductName         string        `json:"productName"         dc:"商品名称"`
	AdminMemberRealName string        `json:"adminMemberRealName" dc:"真实姓名"`
	AdminMemberMobile   string        `json:"adminMemberMobile"   dc:"手机号码"`
	StoreId             int64         `json:"storeId"             dc:"门店ID"`
	MemberId            int64         `json:"memberId"            dc:"核销用户ID"`
}

func (in *OrderVerifyLogListInp) Filter(ctx context.Context) (err error) {
	return
}

type OrderVerifyLogListModel struct {
	Id                  int64             `json:"id"                  dc:"id"`
	Count               int               `json:"count"               dc:"核销数量"`
	CreatedBy           int64             `json:"createdBy"           dc:"核销人"`
	CreatedBySumma      *hook.MemberSumma `json:"createdBySumma"      dc:"核销人摘要信息"`
	CreatedAt           *gtime.Time       `json:"createdAt"           dc:"核销时间"`
	OrderUid            string            `json:"orderUid"            dc:"订单UUID"`
	OrderTraceId        string            `json:"orderTraceId"        dc:"交易ID(流水号)"`
	OrderOrderType      string            `json:"orderOrderType"           dc:"订单类型"`
	OrderStatus         string            `json:"orderStatus"         dc:"订单状态"`
	StoreName           string            `json:"storeName"           dc:"门店名称"`
	StoreAddress        string            `json:"storeAddress"        dc:"门店地址"`
	StorePhone          string            `json:"storePhone"          dc:"门店电话"`
	ProductName         string            `json:"productName"         dc:"商品名称"`
	ProductMainImage    *gjson.Json       `json:"productMainImage"    dc:"商品主图"`
	MemberId            int64             `json:"memberId"            dc:"核销用户ID"`
	AdminMemberNickname string            `json:"adminMemberNickname" dc:"昵称"`
	AdminMemberMobile   string            `json:"adminMemberMobile"   dc:"手机号码"`
}

// OrderVerifyLogExportModel 导出订单核销记录
type OrderVerifyLogExportModel struct {
	Id                  int64       `json:"id"                  dc:"id"`
	OrderId             int64       `json:"orderId"             dc:"订单 id"`
	MemberId            int64       `json:"memberId"            dc:"核销用户 id"`
	ProductId           int64       `json:"productId"           dc:"核销产品"`
	StoreId             int64       `json:"storeId"             dc:"核销商家 id"`
	Count               int         `json:"count"               dc:"核销数量"`
	CreatedBy           int64       `json:"createdBy"           dc:"核销人"`
	CreatedAt           *gtime.Time `json:"createdAt"           dc:"核销时间"`
	OrderUid            string      `json:"orderUid"            dc:"订单UUID"`
	OrderTraceId        string      `json:"orderTraceId"        dc:"交易ID(流水号)"`
	StoreName           string      `json:"storeName"           dc:"门店名称"`
	StoreAddress        string      `json:"storeAddress"        dc:"门店地址"`
	ProductName         string      `json:"productName"         dc:"商品名称"`
	AdminMemberRealName string      `json:"adminMemberRealName" dc:"真实姓名"`
	AdminMemberUsername string      `json:"adminMemberUsername" dc:"帐号"`
}
